const fs = require('fs');

const input = fs.readFileSync(0, 'utf8').trim();

if (!input) {
  process.exit(0);
}

const tokens = input.split(/\s+/).map(Number);
let idx = 0;

const n = tokens[idx++];
const medicines = new Array(n);

for (let i = 0; i < n; i += 1) {
  const pain = tokens[idx++];
  const effect = tokens[idx++];
  medicines[i] = [pain, effect];
}

medicines.sort((a, b) => a[0] - b[0]);

const prefixMax = new Array(n);
let currentMax = 0;

for (let i = 0; i < n; i += 1) {
  currentMax = Math.max(currentMax, medicines[i][1]);
  prefixMax[i] = currentMax;
}

const q = tokens[idx++];
const answers = new Array(q);

for (let qi = 0; qi < q; qi += 1) {
  const limit = tokens[idx++];
  let left = 0;
  let right = n - 1;
  let pos = -1;

  while (left <= right) {
    const mid = (left + right) >> 1;

    if (medicines[mid][0] <= limit) {
      pos = mid;
      left = mid + 1;
    } else {
      right = mid - 1;
    }
  }

  answers[qi] = pos >= 0 ? String(prefixMax[pos]) : '-1';
}

console.log(answers.join('\n'));

